#include<iostream>
#include<unistd.h>
#include<sys/wait.h>
#include<sys/types.h>
using namespace std;

int main()
{
  //cout<<"I am process pid->"<<getpid()<<"ppid->"<<getppid()<<endl;

  //execl("/usr/bin/ls","ls","-l",nullptr);

  //cout<<"I am process pid->"<<getpid()<<"ppid->"<<getppid()<<endl;
  pid_t id = fork();
  if (id == 0)
  {
    cout<<"pid->"<<getpid()<<" "<<"ppid->"<<getppid()<<endl; 
    execl("/usr/bin/ls","ls","-l",nullptr);
  }
  int check = wait(nullptr);
  if (check > 0)
  {
    cout<<"父进程"<<endl;
  }
  return 0;
}
